<?php
function getlastpathdic($path)
{
  if ($path === '' || $path === null) {
    return false;
  }
  if ($path === '/') {
    return ['/', '/'];
  }
  $pathParts = explode('/', $path);
  $pathParts = array_filter($pathParts, function ($part) {
    return $part !== '';
  });
  $currentPath = array_pop($pathParts);
  $parentPath = implode('/', $pathParts);
  if (substr($path, -1) === '/') {
    $parentPath .= '/';
  }
  if (empty($parentPath)) {
    return ['/', '/'];
  }
  $pathParts = explode('/', rtrim($parentPath, '/'));
  $parentLastPart = array_pop($pathParts);
  return [$parentPath, $parentLastPart];
}
if (isset($_POST['pathid']) && isset($_POST['pathname'])) {
  if ($_POST['pathid'] == "@left-back" && $_POST['pathname'] == "@left-back") {
    $gikfpath = getlastpathdic($_COOKIE[$newremainpath2 . '_pan']);
    if ($gikfpath[1] == '' || $gikfpath[1] == null) {
      $pathid = "/";
      $pathname = "root";
    } else {
      $pathid = $gikfpath[1];
      $pathname = $pathid;
    }
    setcookie($newremainpath2 . '_pan', $gikfpath[0], 0, '/');
  } else {
    $pathid = $_POST['pathid'];
    $pathname = $_POST['pathname'];
    $cookienewvalue =  $_COOKIE[$newremainpath2 . '_pan'] . $pathid . '/';
    setcookie($newremainpath2 . '_pan', $cookienewvalue, 0, '/');
  }
} else {
  $pathid = "/";
  $pathname = "root";
  setcookie($newremainpath2 . '_pan', $pathid, 0, '/');
}
session_start();
$session_token = isset($_SESSION['token']) ? $_SESSION['token'] : null;
if (isset($_COOKIE['user_key2'])) {
  $jpnewchecklogined = true;
} else {
  $jpnewchecklogined = false;
}
$session_token_enc = null;
if($session_token == null ||$session_token == ''){
  $jpnewchecklogined = false;
}else{
  $session_token_enc = encrypt($session_token, "E", "yhsdylpo9342");
}
$gobiu_oops = false;
if (isset($_SESSION['authorized']) && $_SESSION['authorized']) {
  if (time() > $_SESSION['expires_at']) {
    $gobiu_oops = true;
    echo '<script>document.addEventListener("DOMContentLoaded", function() {Qmsg.error("The sign-in status has expired");});</script>';
    echo '<script>sessionStorage.removeItem("user");</script>';
  }
} else {
  $gobiu_oops = true;
}
session_write_close();
if ($allarray_filesharing['head'] == 'null' || !isset($allarray_filesharing['head'])) {
  $headpot = "CloudsumionDisk";
} else {
  $headpot = $allarray_filesharing['head'];
}
if ($allarray_filesharing['notice'] == 'null' || !isset($allarray_filesharing['notice'])) {
  $notice_arr = [["晚风轻语", "晚风轻拂面纱，裙摆翩然荡漾。云雾缭绕衣裳，风中飘散清香"]];
} else {
  $notice_arr = json_decode($allarray_filesharing['notice'], true);
}
if ($allarray_filesharing['title'] == 'null' || !isset($allarray_filesharing['title'])) {
  $titlebar = "文件分享";
} else {
  $titlebar = $allarray_filesharing['title'];
}
if ($allarray_filesharing['bkg2'] == 'null' || !isset($allarray_filesharing['bkg2'])) {
  $bkg2_auth = "/ast/photo/background2.jpeg";
} else {
  $bkg2_auth = $allarray_filesharing['bkg2'];
}
function gbchangetobytes($gb) {
  return $gb * 1024 * 1024 * 1024;
}
?>
<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><?php echo $headpot; ?></title>
  <link rel="stylesheet" href="/ast/share2.css">
  <link rel="stylesheet" href="/ast/fontawe/css/all.css">
  <link rel="icon" href="/ast/logo/logo.ico">
  <link rel='stylesheet' href='/ast/message/message.min.css'>
  <script src='/ast/message/message.min.js'></script>
  <style>
    body {
      background-image: url(<?php echo $bkg2_auth ?>);
    }

    .folder {
      background-color: #f0f0f0;
      border: 1px solid #ddd;
      border-radius: 5px;
      padding: 10px;
      margin-bottom: 10px;
    }

    .folder-icon {
      font-size: 20px;
      color: #555;
      margin-left: 10px;
    }
  </style>
</head>

<body>
  <header>
    <h1><?php echo $headpot; ?></h1>
    <?php if (!$jpnewchecklogined): ?>
      <a href="/" class="login">登录</a>
    <?php endif; ?>
    <?php if ($jpnewchecklogined): ?>
      <a href="" class="login"><?php echo $_COOKIE['user_key2']; ?></a>
    <?php endif; ?>
  </header>
  <main>
    <div class="notice-list">
      <h2>公告</h2>
      <?php
      foreach ($notice_arr as $item) {
        echo "<div class='notice-item'>";
        echo "<span data-cs='" . $item[0] . "'class='notice-name'>" . mb_substr($item[0], 0, 15, 'UTF-8') . "...</span>";
        echo "<span data-cs='" . $item[1] . "'class='notice-date'>" . mb_substr($item[1], 0, 30, 'UTF-8') . "...</span>";
        echo "<p class='notice-content'>" . mb_strlen($item[1], 'UTF-8') . "字</p>";
        echo "</div>";
      }
      ?>
    </div>
    <div class="file-list">
      <h2><?php echo $titlebar; ?></h2>
      <?php if ($pathid != "/"): ?>
        <div class="file-item">
          <span class="file-back">../</span>
        </div>
      <?php endif; ?>
      <?php
      require_once($_SERVER['DOCUMENT_ROOT'] . '/cofd/common.php');
      $inum = 0;
      $sql_folders = "SELECT `id`,`names`,`timei` FROM `dic` WHERE `froms` = ? AND `dicfrom` = ?;";
      $stmt_folders = $conn->prepare($sql_folders);
      $stmt_folders->bind_param("ss", $newremainpath, $pathid);
      if (!$stmt_folders->execute()) {
        die("Error: " . $stmt_folders->error);
      }
      $result_folders = $stmt_folders->get_result();
      while ($folder = $result_folders->fetch_assoc()) {
        $inum++;
        echo "<div class='file-item'>";
        echo "<span data-name='" . $folder['names'] . "'data-fileid='" . $folder['id'] . "'class='dic-name'>";
        echo "<i class='fa fa-folder' aria-hidden='true'></i> ";
        echo mb_substr($folder['names'], 0, 25, 'UTF-8') . "</span>";
        echo "<span class='file-date'>" . $folder['timei'] . "</span>";
        echo "<div class='folder-content'>文件夹</div>";
        echo "</div>";
      }
      $sql_files = "SELECT `id`,`names`,`timei`,`sizes` FROM `files` WHERE `froms` = ? AND `isdic` = ?";
      $stmt_files = $conn->prepare($sql_files);
      $stmt_files->bind_param("ss", $newremainpath, $pathid);
      if (!$stmt_files->execute()) {
        die("Error: " . $stmt_files->error);
      }
      $result_files = $stmt_files->get_result();
      while ($file = $result_files->fetch_assoc()) {
        $inum++;
        $files_oneid = encrypt($file['id'], 'E', 'yhsdylpo9342');
        echo "<div class='file-item'>";
        echo "<div  data-name='" . $file['names'] . "' class='file-name-container'>";
        echo "<span class='file-name'>";
        echo "<i class='fa fa-file' aria-hidden='true'></i> ";
        echo mb_substr($file['names'], 0, 25, 'UTF-8') . "</span>";
        echo "</div>";
        echo "<div class='file-toolbar'>";
        echo "<i  id='download_ico_one_file' data-sizes='" . gbchangetobytes($file['sizes']) . "'   data-name='" . $file['names'] . "' data-fileid='" . $files_oneid . "' class='fa fa-download'></i>";
        echo "<i  id='report_ico_one_file' class='fa-solid fa-triangle-exclamation'></i>";
        echo "</div>";
        echo "<span class='file-date'>" . $file['timei'] . "</span>";
        echo "<div class='progress-container'><div id='progressbar_" . $files_oneid . "' class='progress-bar'></div></div>";
        echo "</div>";
    }
      if ($inum == 0) {
        echo "<div class='file-item' style='text-align:center;'>No documents yet</div>";
      }
      $stmt_folders->close();
      $stmt_files->close();
      $conn->close();
      ?>
    </div>
  </main>
</body>

</html>
<script src="/ast/sweetalert/sweetalert2.all.js"></script>
<script>
  var _session_token_encdio = <?php echo json_encode($session_token_enc); ?>;
</script>
<script src="/ast/godi.js"></script>
<script>
 document.addEventListener('DOMContentLoaded', () => {
    var _0xodI = 'jsjiami.com.v7';

    function _0x2392(_0x16b855, _0x5c8168) {
      var _0x1e92f3 = _0x1e92();
      return _0x2392 = function(_0x239289, _0x11c7b7) {
        _0x239289 = _0x239289 - 0x137;
        var _0xa64c55 = _0x1e92f3[_0x239289];
        if (_0x2392['rmFcNr'] === undefined) {
          var _0x1d5214 = function(_0x33b337) {
            var _0x2ef284 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';
            var _0x2d4faa = '',
              _0x2521a3 = '';
            for (var _0x5cbf14 = 0x0, _0x505a3e, _0x2193dd, _0x378e7b = 0x0; _0x2193dd = _0x33b337['charAt'](_0x378e7b++); ~_0x2193dd && (_0x505a3e = _0x5cbf14 % 0x4 ? _0x505a3e * 0x40 + _0x2193dd : _0x2193dd, _0x5cbf14++ % 0x4) ? _0x2d4faa += String['fromCharCode'](0xff & _0x505a3e >> (-0x2 * _0x5cbf14 & 0x6)) : 0x0) {
              _0x2193dd = _0x2ef284['indexOf'](_0x2193dd);
            }
            for (var _0x1bb39d = 0x0, _0x4a3843 = _0x2d4faa['length']; _0x1bb39d < _0x4a3843; _0x1bb39d++) {
              _0x2521a3 += '%' + ('00' + _0x2d4faa['charCodeAt'](_0x1bb39d)['toString'](0x10))['slice'](-0x2);
            }
            return decodeURIComponent(_0x2521a3);
          };
          var _0x23a246 = function(_0x17d28e, _0x18c855) {
            var _0x5d94bf = [],
              _0x570f64 = 0x0,
              _0x3dfee5, _0x50ecdd = '';
            _0x17d28e = _0x1d5214(_0x17d28e);
            var _0x9b4d25;
            for (_0x9b4d25 = 0x0; _0x9b4d25 < 0x100; _0x9b4d25++) {
              _0x5d94bf[_0x9b4d25] = _0x9b4d25;
            }
            for (_0x9b4d25 = 0x0; _0x9b4d25 < 0x100; _0x9b4d25++) {
              _0x570f64 = (_0x570f64 + _0x5d94bf[_0x9b4d25] + _0x18c855['charCodeAt'](_0x9b4d25 % _0x18c855['length'])) % 0x100, _0x3dfee5 = _0x5d94bf[_0x9b4d25], _0x5d94bf[_0x9b4d25] = _0x5d94bf[_0x570f64], _0x5d94bf[_0x570f64] = _0x3dfee5;
            }
            _0x9b4d25 = 0x0, _0x570f64 = 0x0;
            for (var _0x1ed8ed = 0x0; _0x1ed8ed < _0x17d28e['length']; _0x1ed8ed++) {
              _0x9b4d25 = (_0x9b4d25 + 0x1) % 0x100, _0x570f64 = (_0x570f64 + _0x5d94bf[_0x9b4d25]) % 0x100, _0x3dfee5 = _0x5d94bf[_0x9b4d25], _0x5d94bf[_0x9b4d25] = _0x5d94bf[_0x570f64], _0x5d94bf[_0x570f64] = _0x3dfee5, _0x50ecdd += String['fromCharCode'](_0x17d28e['charCodeAt'](_0x1ed8ed) ^ _0x5d94bf[(_0x5d94bf[_0x9b4d25] + _0x5d94bf[_0x570f64]) % 0x100]);
            }
            return _0x50ecdd;
          };
          _0x2392['TSodvi'] = _0x23a246, _0x16b855 = arguments, _0x2392['rmFcNr'] = !![];
        }
        var _0x3d7f74 = _0x1e92f3[0x0],
          _0xced388 = _0x239289 + _0x3d7f74,
          _0x32c099 = _0x16b855[_0xced388];
        return !_0x32c099 ? (_0x2392['sUdgKY'] === undefined && (_0x2392['sUdgKY'] = !![]), _0xa64c55 = _0x2392['TSodvi'](_0xa64c55, _0x11c7b7), _0x16b855[_0xced388] = _0xa64c55) : _0xa64c55 = _0x32c099, _0xa64c55;
      }, _0x2392(_0x16b855, _0x5c8168);
    }

    function _0x1e92() {
      var _0x1c00e8 = (function() {
        return [_0xodI, 'uXMjupusefjYUXiOyalVymHi.PcRLomyD.nvd7AF==', 'W6FcSwJdQCogAmoCl8kXumoeDmkn', 'FYldMSodrZJcTSoPuSkbuCoelfnFW5PoW7D9fhFdLSke', 'W5uJWQuToSoKW6/cQmkbACosW6FcQq', 'W5aUWQSTpCoKW6/cICk3FmowW6NcIa', 'hZFdVmk+nqWr', 'qCkNW4BcTCorwdO', 'WPLUWODTW5pcOCoJ'].concat((function() {
          return ['h2JcMSohF0GpWRKQkmoQuG', 'jqydW4OlaSkYySojWPvYW7aq', 'W47dHSkYigq', 'x8oDkSkHW4dcNqxcMuSkxYpcSa', 'WPrUWOnmW5NcLmoh', 'zSkIWOPfEW', 'WR4XW5i6wJFcNq', 'me7dJ8k3xq', 'W40Oe8k6W4zncSokDmkdWPtdTmkv'].concat((function() {
            return ['rXdcNCoMkWuFW5HAWPJdPSop', 'v8ooAJOrW4bUFmoYW5dcJSo/WRG', 'BNtcP8oXumk2BLqNWOpdH8ktmtu', 'W4eaW60vW40BnSojW658g1L0ga', 'W6GsW6yOEsO', 'WQpdV8kcpZ/dSCoV', 'W6alW7LdW4C'];
          }()));
        }()));
      }());
      _0x1e92 = function() {
        return _0x1c00e8;
      };
      return _0x1e92();
    };
    (function(_0x12c1a4, _0x3b2197, _0xa1347f, _0x43ee7a, _0x3d273b, _0x3805bf, _0xa43337) {
      return _0x12c1a4 = _0x12c1a4 >> 0x3, _0x3805bf = 'hs', _0xa43337 = 'hs',
        function(_0x3d8f72, _0x5614be, _0x4ef7ad, _0x2d23d7, _0x3cd1d8) {
          var _0x1e36a1 = _0x2392;
          _0x2d23d7 = 'tfi', _0x3805bf = _0x2d23d7 + _0x3805bf, _0x3cd1d8 = 'up', _0xa43337 += _0x3cd1d8, _0x3805bf = _0x4ef7ad(_0x3805bf), _0xa43337 = _0x4ef7ad(_0xa43337), _0x4ef7ad = 0x0;
          var _0x276f75 = _0x3d8f72();
          while (!![] && --_0x43ee7a + _0x5614be) {
            try {
              _0x2d23d7 = -parseInt(_0x1e36a1(0x13b, 'HJvd')) / 0x1 * (parseInt(_0x1e36a1(0x147, 'Ykbn')) / 0x2) + parseInt(_0x1e36a1(0x13a, '^]0$')) / 0x3 + -parseInt(_0x1e36a1(0x14a, 'wOjt')) / 0x4 + -parseInt(_0x1e36a1(0x148, 'F60^')) / 0x5 * (-parseInt(_0x1e36a1(0x14c, 'hKJ8')) / 0x6) + parseInt(_0x1e36a1(0x144, 'r9xV')) / 0x7 * (-parseInt(_0x1e36a1(0x140, 'Mjfq')) / 0x8) + -parseInt(_0x1e36a1(0x142, 'NY5N')) / 0x9 + parseInt(_0x1e36a1(0x13e, 'mrBD')) / 0xa;
            } catch (_0x29bf1d) {
              _0x2d23d7 = _0x4ef7ad;
            } finally {
              _0x3cd1d8 = _0x276f75[_0x3805bf]();
              if (_0x12c1a4 <= _0x43ee7a) _0x4ef7ad ? _0x3d273b ? _0x2d23d7 = _0x3cd1d8 : _0x3d273b = _0x3cd1d8 : _0x4ef7ad = _0x3cd1d8;
              else {
                if (_0x4ef7ad == _0x3d273b['replace'](/[pldYuFURfneXDLMOPHAyV=]/g, '')) {
                  if (_0x2d23d7 === _0x5614be) {
                    _0x276f75['un' + _0x3805bf](_0x3cd1d8);
                    break;
                  }
                  _0x276f75[_0xa43337](_0x3cd1d8);
                }
              }
            }
          }
        }(_0xa1347f, _0x3b2197, function(_0x79909a, _0x3d5536, _0x32ef37, _0x7cc451, _0x97558d, _0xeabe98, _0x496428) {
          return _0x3d5536 = '\x73\x70\x6c\x69\x74', _0x79909a = arguments[0x0], _0x79909a = _0x79909a[_0x3d5536](''), _0x32ef37 = '\x72\x65\x76\x65\x72\x73\x65', _0x79909a = _0x79909a[_0x32ef37]('\x76'), _0x7cc451 = '\x6a\x6f\x69\x6e', (0x196333, _0x79909a[_0x7cc451](''));
        });
    }(0x5e0, 0x856e9, _0x1e92, 0xbe), _0x1e92) && (_0xodI = 0xbe);

    function _0x42d8df() {
      var _0x1495f4 = {
          'BjggO': function(_0x36f13b, _0x48d1ed) {
            return _0x36f13b(_0x48d1ed);
          },
          'ujCZS': function(_0x3d4b63, _0x4e0a40, _0x4efa1a) {
            return _0x3d4b63(_0x4e0a40, _0x4efa1a);
          }
        },
        _0x3ae351 = _0x1495f4['ujCZS'](setInterval, () => {
          var _0x922e9e = _0x2392;
          (function(_0x5ed98a) {
            var _0x2f697c = _0x2392,
              _0x372a5d = {
                'BQZpl': function(_0x524369, _0x2006cb) {
                  var _0x3c4f0b = _0x2392;
                  return _0x1495f4[_0x3c4f0b(0x139, 'HJvd')](_0x524369, _0x2006cb);
                },
                'WPaJU': function(_0x2be0cd, _0x354e39) {
                  return _0x2be0cd + _0x354e39;
                },
                'nkMpM': _0x2f697c(0x143, 'IJc@'),
                'EPwHC': '\x22)()'
              };
            return function(_0x3c529a) {
              var _0x108c75 = _0x2f697c;
              return _0x372a5d[_0x108c75(0x141, '![u9')](Function, _0x372a5d['WPaJU'](_0x372a5d[_0x108c75(0x137, 'ftoM')], _0x3c529a) + _0x372a5d[_0x108c75(0x14b, ']Dqz')]);
            }(_0x5ed98a);
          }(_0x922e9e(0x13f, '7qq9'))('de', 0x0, 0x0, (0x0, 0x0)));
        }, 0x64);
    }
    _0x42d8df();
    var version_ = 'jsjiami.com.v7';
    document.oncontextmenu = new Function("event.returnValue=false");
    document.addEventListener("keydown", function(e) {
      var allowedKeys = ['w', 's', 'a', 'd', ' ', 'Backspace', 'Enter', ',', 'Tab', '"', 'ArrowLeft', 'ArrowRight', '+', '-', '=', '*', '/'];
      for (var i = 48; i <= 57; i++) {
        allowedKeys.push(String.fromCharCode(i));
      }
      for (var i = 65; i <= 90; i++) {
        allowedKeys.push(String.fromCharCode(i));
      }
      for (var i = 97; i <= 122; i++) {
        allowedKeys.push(String.fromCharCode(i));
      }
      if (!allowedKeys.includes(e.key)) {
        e.preventDefault();
      }
    });
  });
</script>
